package com.bwda.dsrs.util;

import com.bwda.dsrs.domain.po.adminlog.AdminLogPo;
import com.bwda.dsrs.domain.po.serverslog.LogTemplate;
import com.bwda.dsrs.domain.po.surfacelog.SurfaceLogPo;
import com.bwda.dsrs.domain.po.userlog.UserLogPo;
import com.bwda.dsrs.service.AdminLogService;
import com.bwda.dsrs.service.SurfaceLogService;
import com.bwda.dsrs.service.UserLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 日志服务工具类
 * @author yanyuemei
 * @date 2019/4/16
 */
@Component
public class LogServiceUtil {

    private static final Logger log = LoggerFactory.getLogger(LogServiceUtil.class);


    @Autowired
    private AdminLogService adminLogService;

    @Autowired
    private UserLogService userLogService;

    @Autowired
    private SurfaceLogService surfaceLogService;



    /**
     * 服务调用处理
     */
    public void handleLogServiceUtil(LogTemplate logTemplate) {
        Integer id = logTemplate.getId();
        handleLogUtil(id,logTemplate);
    }


    /**
     * 日志服务调用处理
     */
    public void handleLogUtil(Integer id, LogTemplate logTemplate) {
        switch (id) {
            case 1:
                //处理系统服务日志
                handleSystemLogUtil(logTemplate);
                break;
            case 2:
                //处理用户服务日志
                handleUserLogUtil(logTemplate);
                break;
            case 3:
                //处理外部服务日志
                handleSurfaceLogUtil(logTemplate);
                break;
            default:
                break;
        }
    }
    /**
     *管理服务调用处理
     */
    public void handleSystemLogUtil(LogTemplate logTemplate){
        AdminLogPo adminLogPo = logTemplate.getAdminLogPo();
        adminLogService.handleSystemLog(adminLogPo);
//
    }

    /**
     * 用户服务调用处理
     */
    public void handleUserLogUtil(LogTemplate logTemplate){
        UserLogPo userLogPo = logTemplate.getUserLogPo();
        userLogService.handleSystemLog(userLogPo);
    }

    /**
     * 外部服务调用处理
     */
    public void handleSurfaceLogUtil(LogTemplate logTemplate){
        SurfaceLogPo surfaceLogPo = logTemplate.getSurfaceLogPo();
        surfaceLogService.handleSystemLog(surfaceLogPo);
    }
}